import { HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Menu } from '../model/menu';
import { PaginationList } from '../model/message';
import { CommonApi } from './commonApi';
import { RequestService } from './request.service';

@Injectable()
export class MenuApiService extends CommonApi<Menu>{

  private requestUrl = '/menu';
  constructor(
    private request: RequestService
  ) {
    super(request, '/menu');
  }

  public fetchListInParent(parentId: number, param: HttpParams): Observable<PaginationList<Menu>> {
    const url = this.requestUrl +  '/list/' + parentId;
    return this.request.get(url, param);
  }
}
